package com.alcj.service.impl;

import com.alcj.mapper.AddressMapper;
import com.alcj.model.Address;
import com.alcj.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by jdz on 2017/10/30.
 */

@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    AddressMapper addressMapper;

    /**
     * 查询本用户的所有收货地址
     * @param sysUserId
     * @return
     */
    @Override
    public List<Address> getAddressInfos(String sysUserId) {

        return this.addressMapper.selectListByOperaId(sysUserId);
    }


    /**
     * 插入地址
     * @param record
     * @return
     */
    @Override
    public int setAddressInfo(Address record) {
        return this.addressMapper.insert(record);
    }

    /**
     * 修改地址
     * @param address
     * @return
     */
    @Override
    public int updateAddressInfo(Address address){
        return this.addressMapper.updateByPrimaryKey(address);
    }

    /**
     * 删除地址
     * @param address
     * @return
     */
    @Override
    public int deleteAddress(Address address){
        return this.addressMapper.deleteByPrimaryKey(address.getAddressid());
    }

    @Override
    public int updatedelFlagByOperaId(String sysUserId) {
        return this.addressMapper.updatedelFlagByOperaId(sysUserId);
    }

    @Override
    public int updatedelFlagByPrimaryKey(String addressId) {
        return this.addressMapper.updatedelFlagByPrimaryKey(addressId);
    }

//    /**
//     *查询本用户的总条数
//     * @return
//     */
//    @Override
//    public String getAddressInfoSize() {
//        return this.addressMapper.selectAddressInfoSize();
//    }


    /**
     * 查询本条地址信息
     * @param addressId
     * @return
     */
    @Override
    public Address getAddressInfo(String addressId){
        return this.addressMapper.selectByPrimaryKey(addressId);
    }
}
